#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <unordered_map>

using namespace std;

////class Solution {
////public:
////    string removeKdigits(string num, int k)
////    {
////        deque<char> monoSt;
////        for (int i = 0; i < num.size(); ++i)
////        {
////            char curNum = num[i];
////            while (k > 0 && !monoSt.empty() && monoSt.back() > curNum) {
////                monoSt.pop_back();
////                --k;
////            }
////            monoSt.push_back(curNum);
////        }
////        while (k > 0) { monoSt.pop_back(); }
////        string res;
////        while (!monoSt.empty())
////        {
////            while (monoSt.front() == '0') { monoSt.pop_front(); }
////            res += monoSt.front();
////            monoSt.pop_front();
////        }
////        return res;
////    }
////};
//
//class Solution {
//public:
//    vector<string> findRelativeRanks(vector<int>& score)
//    {
//        int n = score.size();
//        vector<int> tmpScore(score.begin(), score.end());
//        sort(tmpScore.begin(), tmpScore.end());
//        unordered_map<int, int> ranksMap; // score - rank
//        for (int i = 0; i < n; ++i) {
//            int sc = tmpScore[i];
//            ranksMap.insert(make_pair(sc, i + 1));
//        }
//        vector<string> res;
//        for (int i = 0; i < n; ++i) {
//            int rank = ranksMap[score[i]];
//            if (rank == 1) { res.push_back("Gold Medal"); }
//            else if (rank == 2) { res.push_back("Silver Medal"); }
//            else if (rank == 3) { res.push_back("Bronze Medal"); }
//            else { res.push_back(to_string(rank)); }
//        }
//        return res;
//    }
//};

class Solution {
public:
    vector<string> findRelativeRanks(vector<int>& score) {
        int n = score.size();
        string desc[3] = {"Gold Medal", "Silver Medal", "Bronze Medal"};
        vector<pair<int, int>> arr;

        for (int i = 0; i < n; ++i) {
            arr.emplace_back(make_pair(-score[i], i));
        }
        sort(arr.begin(), arr.end());
        vector<string> ans(n);
        for (int i = 0; i < n; ++i) {
            if (i >= 3) {
                ans[arr[i].second] = to_string(i + 1);
            } else {
                ans[arr[i].second] = desc[i];
            }
        }
        return ans;
    }
};

int main()
{
   Solution s;
   //s.removeKdigits("10200", 1);
   vector<int> v{5, 4, 3 ,2 ,1 };
   s.findRelativeRanks(v);
   return 0;
}
